home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / ROM_Kernel_Manuals / Lib_examples / filereq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-20  |  2.0 KB  |  71 lines

  1. ;/* filereq.c - Execute me to compile me with SASC 5.10
  2. LC -b1 -cfistq -v -y -j73 filereq.c
  3. Blink FROM LIB:c.o,filereq.o TO filereq LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit
  5. **
  6. ** Here's a short example showing how to create a file requester with
  7. ** asl.library.  If AslRequest() returns TRUE then the rf_File and
  8. ** rf_Dir fields of the requester data structure contain the name and
  9. ** directory of the file the user selected.  Note that the user can type
  10. ** in the a name for the file and directory, which makes it possible for
  11. ** a file requester to return a file and directory that do not
  12. ** (currently) exist.
  13. */
  14. #include <exec/types.h>
  15. #include <exec/libraries.h>
  16. #include <libraries/asl.h>
  17. #include <clib/exec_protos.h>
  18. #include <clib/asl_protos.h>
  19. #include <stdio.h>
  20.  
  21. #ifdef LATTICE
  22. int CXBRK(void)     { return(0); }  /* Disable Lattice CTRL/C handling */
  23. void chkabort(void) { return; }     /* really */
  24. #endif
  25.  
  26. UBYTE *vers = "$VER: filereq 37.0";
  27.  
  28. #define MYLEFTEDGE 0
  29. #define MYTOPEDGE  0
  30. #define MYWIDTH    320
  31. #define MYHEIGHT   400
  32.  
  33. struct Library *AslBase = NULL;
  34.  
  35. struct TagItem frtags[] =
  36. {
  37.     ASL_Hail,       (ULONG)"The RKM file requester",
  38.     ASL_Height,     MYHEIGHT,
  39.     ASL_Width,      MYWIDTH,
  40.     ASL_LeftEdge,   MYLEFTEDGE,
  41.     ASL_TopEdge,    MYTOPEDGE,
  42.     ASL_OKText,     (ULONG)"O KAY",
  43.     ASL_CancelText, (ULONG)"not OK",
  44.     ASL_File,       (ULONG)"asl.library",
  45.     ASL_Dir,        (ULONG)"libs:",
  46.     TAG_DONE
  47. };
  48.  
  49. void main(int argc, char **argv)
  50. {
  51.     struct FileRequester *fr;
  52.  
  53.     if (AslBase = OpenLibrary("asl.library", 37L))
  54.     {
  55.         if (fr = (struct FileRequester *)
  56.             AllocAslRequest(ASL_FileRequest, frtags))
  57.         {
  58.             if (AslRequest(fr, NULL))
  59.             {
  60.                 printf("PATH=%s  FILE=%s\n", fr->rf_Dir, fr->rf_File);
  61.                 printf("To combine the path and filename, copy the path\n");
  62.                 printf("to a buffer, add the filename with Dos AddPart().\n");
  63.             }
  64.             FreeAslRequest(fr);
  65.         }
  66.         else printf("User Cancelled\n");
  67.  
  68.         CloseLibrary(AslBase);
  69.     }
  70. }
  71.